package ACM.ZhongAn;

import java.util.ArrayList;
import java.util.Scanner;

/**
 * @author way
 * @create 2025-04-10 19:33
 */
public class _0410_1 {
    // 定义内部类保存连续字符段的信息
    static class Segment {
        char c;    // 字符
        int len;   // 连续长度

        public Segment(char c, int len) {
            this.c = c;
            this.len = len;
        }
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next().trim();  // 读取输入并去除首尾空格

        // 处理空字符串情况
        if (s.isEmpty()) {
            System.out.println(0);
            sc.close();
            return;
        }

        ArrayList<Segment> segments = new ArrayList<>();
        char currentChar = s.charAt(0);
        int currentLength = 1;

        // 遍历字符串，分割连续字符段
        for (int i = 1; i < s.length(); i++) {
            char c = s.charAt(i);
            if (c == currentChar) {
                currentLength++;
            } else {
                segments.add(new Segment(currentChar, currentLength));
                currentChar = c;
                currentLength = 1;
            }
        }
        segments.add(new Segment(currentChar, currentLength));

        // 计算普通情况下的最大长度
        int max = 0;
        for (Segment seg : segments) {
            if (seg.len > max) {
                max = seg.len;
            }
        }

        // 处理环形首尾相接的情况
        if (segments.size() > 1) {  // 至少需要两个段才可能首尾相接
            Segment first = segments.get(0);
            Segment last = segments.get(segments.size() - 1);
            if (first.c == last.c) {
                int combined = first.len + last.len;
                if (combined > max) {
                    max = combined;
                }
            }
        }

        System.out.println(max);
        sc.close();
    }
}

